<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Cluster APIs | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'cluster.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/cluster.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/cluster.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/cluster.html" rel="nofollow" target="_blank">../en/cluster.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-node">Cluster APIs</span>
</div>
<div class="navheader">
<span class="prev">
<a href="cat-transforms.html">« cat transforms API</a>
</span>
<span class="next">
<a href="cluster-allocation-explain.html">Cluster allocation explain API »</a>
</span>
</div>
<div class="chapter">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="cluster"></a>Cluster APIs<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cluster.asciidoc">edit</a>
</h2>
</div></div></div>
<h3>
<a id="cluster-nodes"></a>Node specification<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cluster.asciidoc">edit</a>
</h3>
<p>Some cluster-level APIs may operate on a subset of the nodes which can be
specified with <em>node filters</em>. For example, the <a class="xref" href="tasks.html" title="Task management API">Task Management</a>,
<a class="xref" href="cluster-nodes-stats.html" title="Nodes stats API">Nodes Stats</a>, and <a class="xref" href="cluster-nodes-info.html" title="Nodes info API">Nodes Info</a> APIs
can all report results from a filtered set of nodes rather than from all nodes.</p>
<p><em>Node filters</em> are written as a comma-separated list of individual filters,
each of which adds or removes nodes from the chosen subset. Each filter can be
one of the following:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">_all</code>, to add all nodes to the subset.
</li>
<li class="listitem">
<code class="literal">_local</code>, to add the local node to the subset.
</li>
<li class="listitem">
<code class="literal">_master</code>, to add the currently-elected master node to the subset.
</li>
<li class="listitem">
a node id or name, to add this node to the subset.
</li>
<li class="listitem">
an IP address or hostname, to add all matching nodes to the subset.
</li>
<li class="listitem">
a pattern, using <code class="literal">*</code> wildcards, which adds all nodes to the subset
whose name, address or hostname matches the pattern.
</li>
<li class="listitem">
<code class="literal">master:true</code>, <code class="literal">data:true</code>, <code class="literal">ingest:true</code>, <code class="literal">voting_only:true</code>, <code class="literal">ml:true</code>, or
<code class="literal">coordinating_only:true</code>, which respectively add to the subset all
master-eligible nodes, all data nodes, all ingest nodes, all voting-only
nodes, all machine learning nodes, and all coordinating-only nodes.
</li>
<li class="listitem">
<code class="literal">master:false</code>, <code class="literal">data:false</code>, <code class="literal">ingest:false</code>, <code class="literal">voting_only:true</code>, <code class="literal">ml:false</code>,
or <code class="literal">coordinating_only:false</code>, which respectively remove from the subset all
master-eligible nodes, all data nodes, all ingest nodes, all voting-only
nodes, all machine learning nodes, and all coordinating-only nodes.
</li>
<li class="listitem">
a pair of patterns, using <code class="literal">*</code> wildcards, of the form <code class="literal">attrname:attrvalue</code>,
which adds to the subset all nodes with a custom node attribute whose name
and value match the respective patterns. Custom node attributes are
configured by setting properties in the configuration file of the form
<code class="literal">node.attr.attrname: attrvalue</code>.
</li>
</ul>
</div>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>node filters run in the order in which they are given, which is important
if using filters that remove nodes from the set. For example
<code class="literal">_all,master:false</code> means all the nodes except the master-eligible ones, but
<code class="literal">master:false,_all</code> means the same as <code class="literal">_all</code> because the <code class="literal">_all</code> filter runs
after the <code class="literal">master:false</code> filter.</p>
</div>
</div>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>if no filters are given, the default is to select all nodes. However, if
any filters are given then they run starting with an empty chosen subset. This
means that filters such as <code class="literal">master:false</code> which remove nodes from the chosen
subset are only useful if they come after some other filters. When used on its
own, <code class="literal">master:false</code> selects no nodes.</p>
</div>
</div>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>The <code class="literal">voting_only</code> role requires the default distribution of Elasticsearch and
is not supported in the OSS-only distribution.</p>
</div>
</div>
<p>Here are some examples of the use of node filters with the
<a class="xref" href="cluster-nodes-info.html" title="Nodes info API">Nodes Info</a> APIs.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console"># If no filters are given, the default is to select all nodes
GET /_nodes
# Explicitly select all nodes
GET /_nodes/_all
# Select just the local node
GET /_nodes/_local
# Select the elected master node
GET /_nodes/_master
# Select nodes by name, which can include wildcards
GET /_nodes/node_name_goes_here
GET /_nodes/node_name_goes_*
# Select nodes by address, which can include wildcards
GET /_nodes/10.0.0.3,10.0.0.4
GET /_nodes/10.0.0.*
# Select nodes by role
GET /_nodes/_all,master:false
GET /_nodes/data:true,ingest:true
GET /_nodes/coordinating_only:true
GET /_nodes/master:true,voting_only:false
# Select nodes by custom attribute (e.g. with something like `node.attr.rack: 2` in the configuration file)
GET /_nodes/rack:2
GET /_nodes/ra*:2
GET /_nodes/ra*:2*</pre>
</div>
<div class="console_widget" data-snippet="snippets/1385.console"></div>
















</div>
<div class="navfooter">
<span class="prev">
<a href="cat-transforms.html">« cat transforms API</a>
</span>
<span class="next">
<a href="cluster-allocation-explain.html">Cluster allocation explain API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>